package guoanmaker.operator.business.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import guoanmaker.operator.business.model.BackgroundPicture;
import guoanmaker.operator.business.model.OperatorFriendshipLink;
import guoanmaker.operator.business.model.OperatorManage;
import guoanmaker.operator.business.repository.OperatorBackgroundPictureRepository;
import guoanmaker.operator.business.repository.OperatorFriendshipLinkRepository;
import guoanmaker.operator.business.repository.OperatorManageRepository;

@Service
public class OperatorBackLoginService implements OperatorBackLoginServiceInterface {
	@Autowired
	private OperatorBackgroundPictureRepository operatorBackgroundPictureRepository;
	@Autowired
	private OperatorManageRepository operatorManageRepository;
	@Autowired
	private  OperatorFriendshipLinkRepository operatorFriendshipLinkRepository;
	public Map selectBackLogin(){
		Map<String, Object> reMap = new HashMap<>();
		List<BackgroundPicture> bps=operatorBackgroundPictureRepository.findAll();
		BackgroundPicture backgroundPicture=null;
		if(bps.size()>0){
			backgroundPicture=bps.get(0);
			
		}
		reMap.put("backgroundPicture", backgroundPicture);
		
		List<OperatorManage> manages=operatorManageRepository.findAll();
		OperatorManage operatorManage=null;
		if(manages.size()>0){
			operatorManage=manages.get(0);
		}
		reMap.put("operatorManage", operatorManage);
		List<OperatorFriendshipLink> friendships=operatorFriendshipLinkRepository.findByType("2");
		
		reMap.put("friendships", friendships);
		return reMap;
	}
}
